package com.codi.bus.core.service.impl;

import com.codi.bus.core.dao.FundCombinationMappingDao;
import com.codi.bus.core.domain.FundCombinationMapping;
import com.codi.bus.core.service.FundCombinationMappingService;
import com.codi.bus.core.service.FundCombinationService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional(readOnly = true)
public class FundCombinationMappingServiceImpl implements FundCombinationMappingService{
    @Resource
    private FundCombinationMappingDao fundCombinationMappingDao;

    @Override
    public List<FundCombinationMapping> queryByCombinationCode(String combinationCode) {
        return fundCombinationMappingDao.query(combinationCode);
    }

    @Override
    public FundCombinationMapping queryByCombinationCodeAndFundCode(String combinationCode, String fundCode) {
        return fundCombinationMappingDao.query(combinationCode, fundCode);
    }

    @Override
    @Transactional(readOnly = false)
    public int add(FundCombinationMapping mapping) {
        return fundCombinationMappingDao.add(mapping);
    }

    @Override
    @Transactional(readOnly = false)
    public int update(FundCombinationMapping mapping) {
        return fundCombinationMappingDao.updateMapping(mapping);
    }

    @Override
    @Transactional(readOnly = false)
    public int delete(Long mappingId) {
        return fundCombinationMappingDao.delete(mappingId);
    }

    @Override
    @Transactional(readOnly = false)
    public int deleteCombination(String combinationCode) {
        return fundCombinationMappingDao.deleteByCombinationCode(combinationCode.trim());
    }

    @Override
    public FundCombinationMapping queryByPrimaryKey(Long mappingId) {
        return fundCombinationMappingDao.queryByPrimaryKey(mappingId);
    }
}
